diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..cb0ef2d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,10 @@
+*.png
+target/
+local.log
+.idea
+*.iml
+**/.DS_Store
+**/.settings
+.classpath
+.project
+
diff --git a/README.md b/README.md
index 446876b..ef3660d 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,2 @@
-App Automate Java Samples
----------------------
-
-This repository contains code for Automated Native App tests using Appium in Java. Please feel free to clone the repo and use the example code.
-
-For frameworks integration with BrowserStack, refer to their individual repositories -
-
-- [JUnit](https://github.com/browserstack/junit-appium-app-browserstack)
-- [TestNg](https://github.com/browserstack/testng-appium-app-browserstack)
\ No newline at end of file
+| [Using Java 7 client with MJSONWP protocol](./java_7) | [Using Java 8 client with w3c protocol](./java_8) |
+|------------------------------------------------------ | ------------------------------------------------- |
\ No newline at end of file
diff --git a/android/BrowserStackAndroid.java b/android/BrowserStackAndroid.java
deleted file mode 100644
index c4e759e..0000000
--- a/android/BrowserStackAndroid.java
+++ /dev/null
@@ -1,39 +0,0 @@
-import java.net.URL;
-import java.util.List;
-import java.net.MalformedURLException;
-import io.appium.java_client.android.AndroidDriver;
-
-import org.openqa.selenium.By;
-import org.openqa.selenium.WebElement;
-import org.openqa.selenium.support.ui.ExpectedConditions;
-import org.openqa.selenium.support.ui.WebDriverWait;
-import org.openqa.selenium.remote.DesiredCapabilities;
-
-public class BrowserStackAndroid {
-	
-    public static String accessKey = "BROWSERSTACK_USERNAME";
-    public static String userName = "BROWSERSTACK_ACCESS_KEY";
-
-    public static void main(String args[]) throws MalformedURLException, InterruptedException {
-        DesiredCapabilities capabilities = new DesiredCapabilities();
-
-        capabilities.setCapability("realMobile", true);
-        capabilities.setCapability("device", "Samsung Galaxy S7");
-        capabilities.setCapability("app", "bs://<hashed app-id>");
-
-        AndroidDriver driver = new AndroidDriver(new URL("https://"+userName+":"+accessKey+"@hub.browserstack.com/wd/hub"), capabilities);
-
-        WebElement searchElement = new WebDriverWait(driver, 30).until(
-            ExpectedConditions.elementToBeClickable(By.id("Search Wikipedia")));
-        searchElement.click();
-        WebElement insertTextElement = new WebDriverWait(driver, 30).until(
-            ExpectedConditions.elementToBeClickable(By.id("org.wikipedia.alpha:id/search_src_text")));
-        insertTextElement.sendKeys("BrowserStack");
-        Thread.sleep(5000);
-
-        List<WebElement> allProductsName = driver.findElements(By.className("android.widget.TextView"));
-        assert(allProductsName.size() > 0);
-
-        driver.quit();
-    }
-}
diff --git a/android/LocalSampleAndroid.java b/android/LocalSampleAndroid.java
deleted file mode 100644
index 00aaf17..0000000
--- a/android/LocalSampleAndroid.java
+++ /dev/null
@@ -1,74 +0,0 @@
-import com.browserstack.local.Local;
-
-import java.net.URL;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import io.appium.java_client.android.AndroidDriver;
-
-import org.openqa.selenium.By;
-import org.openqa.selenium.WebElement;
-import org.openqa.selenium.support.ui.ExpectedConditions;
-import org.openqa.selenium.support.ui.WebDriverWait;
-import org.openqa.selenium.remote.DesiredCapabilities;
-
-
-public class LocalSampleAndroid {
-    private static Local localInstance;
-    public static String accessKey = "BROWSERSTACK_USERNAME";
-    public static String userName = "BROWSERSTACK_ACCESS_KEY";
-  
-
-    public static void setupLocal() throws Exception {
-      localInstance = new Local();
-      Map<String, String> options = new HashMap<String, String>();
-      options.put("key", accessKey);
-      localInstance.start(options);
-    }
-
-    public static void tearDownLocal() throws Exception {
-      localInstance.stop();
-    }
-
-    public static void main(String[] args) throws Exception {
-        setupLocal();
-
-        DesiredCapabilities capabilities = new DesiredCapabilities();
-
-        capabilities.setCapability("browserstack.local", true);
-        capabilities.setCapability("realMobile", true);
-        capabilities.setCapability("device", "Samsung Galaxy S7");
-        capabilities.setCapability("app", "bs://<hashed app-id>");
-
-        AndroidDriver driver = new AndroidDriver(new URL("https://"+userName+":"+accessKey+"@hub.browserstack.com/wd/hub"), capabilities);
-
-        WebElement searchElement = new WebDriverWait(driver, 30).until(
-            ExpectedConditions.elementToBeClickable(By.id("com.example.android.basicnetworking:id/test_action")));
-        searchElement.click();
-        WebElement insertTextElement = new WebDriverWait(driver, 30).until(
-            ExpectedConditions.elementToBeClickable(By.className("android.widget.TextView")));
-
-        WebElement testElement = null;
-        List<WebElement> allTextViewElements = driver.findElements(By.className("android.widget.TextView"));
-        Thread.sleep(10);
-        for(WebElement textElement : allTextViewElements) {
-          System.out.println(textElement.getText());
-          if(textElement.getText().contains("The active connection is")) {
-            testElement = textElement;
-          }
-        }
-
-        if(testElement == null) {
-          throw new Error("Cannot find the needed TextView element from app");
-        }
-        String matchedString = testElement.getText();
-        System.out.println(matchedString);
-        assert(matchedString.contains("The active connection is wifi"));
-        assert(matchedString.contains("Up and running"));
-
-        driver.quit();
-
-        tearDownLocal();
-    }
-}
diff --git a/android/README.md b/android/README.md
deleted file mode 100644
index 56d99bb..0000000
--- a/android/README.md
+++ /dev/null
@@ -1,16 +0,0 @@
-## Running your tests
-- Do remember to switch the USERNAME and ACCESS_KEY with your own browserstack credentials.
-- Upload your Native App (.apk file) to BrowserStack servers using upload API:
-
-  ```
-  curl -u "username:accesskey" -X POST "https://api.browserstack.com/app-automate/upload" -F "file=@/path/to/app/file/Application-debug.apk"
-  ```
-
-- If you do not have an .apk file and looking to simply try App Automate, [you can download our sample app and upload](https://www.browserstack.com/app-automate/sample-apps/android/WikipediaSample.apk)
-to the BrowserStack servers using the above API.
-- Update the desired capability "app" with the App URL returned from the above API call
-
-For frameworks integration with BrowserStack, refer to their individual repositories -
-
-- [JUnit](https://github.com/browserstack/junit-appium-app-browserstack)
-- [TestNG](https://github.com/browserstack/testng-appium-app-browserstack)
diff --git a/ios/BrowserStackIOS.java b/ios/BrowserStackIOS.java
deleted file mode 100644
index 0477652..0000000
--- a/ios/BrowserStackIOS.java
+++ /dev/null
@@ -1,60 +0,0 @@
-import java.net.URL;
-import java.util.List;
-import java.net.MalformedURLException;
-
-import org.openqa.selenium.support.ui.WebDriverWait;
-import org.openqa.selenium.remote.DesiredCapabilities;
-import org.openqa.selenium.support.ui.ExpectedConditions;
-
-import io.appium.java_client.MobileBy;
-import io.appium.java_client.ios.IOSDriver;
-import io.appium.java_client.ios.IOSElement;
-
-
-public class BrowserStackIOS {
-    public static String accessKey = "BROWSERSTACK_USERNAME";
-    public static String userName = "BROWSERSTACK_ACCESS_KEY";
-
-    public static void main(String args[]) throws MalformedURLException, InterruptedException {
-        DesiredCapabilities capabilities = new DesiredCapabilities();
-
-        capabilities.setCapability("realMobile", true);
-        capabilities.setCapability("device", "iPhone 7");
-        capabilities.setCapability("app", "bs://<hashed app-id>");
-        capabilities.setCapability("automationName", "XCUITest");
-
-        IOSDriver<IOSElement> driver = new IOSDriver<IOSElement>(new URL("http://"+userName+":"+accessKey+"@hub.browserstack.com/wd/hub"), capabilities);
-
-        IOSElement loginButton = (IOSElement) new WebDriverWait(driver, 30).until(
-            ExpectedConditions.elementToBeClickable(MobileBy.AccessibilityId("Log In")));
-        loginButton.click();
-        IOSElement emailTextField = (IOSElement) new WebDriverWait(driver, 30).until(
-            ExpectedConditions.elementToBeClickable(MobileBy.AccessibilityId("Email address")));
-
-        // element.sendKeys() method is not supported in Appium 1.6.3
-        // Workaround for sendKeys() method:
-        emailTextField.click();
-        String email = "hello@browserstack.com";
-        for (int i = 0; i < email.length(); i++) {
-          driver.findElementByXPath("//XCUIElementTypeKey[@name='" + email.charAt(i) + "']").click();
-        }
-
-        driver.findElementByAccessibilityId("Next").click();      
-        Thread.sleep(5000);
-
-        List<IOSElement> textElements = driver.findElementsByXPath("//XCUIElementTypeStaticText");
-        assert(textElements.size() > 0);
-        String matchedString = "";
-        for(IOSElement textElement : textElements) {
-          String textContent = textElement.getText();
-          if(textContent.contains("not registered")) {
-            matchedString = textContent;
-          }
-        }
-
-        System.out.println(matchedString);
-        assert(matchedString.contains("not registered on WordPress.com"));
-
-        driver.quit();
-    }
-}
diff --git a/ios/README.md b/ios/README.md
deleted file mode 100644
index dd76f1e..0000000
--- a/ios/README.md
+++ /dev/null
@@ -1,16 +0,0 @@
-## Running your tests
-- Do remember to switch the USERNAME and ACCESS_KEY with your own browserstack credentials.
-- Upload your Native App (.ipa file) to BrowserStack servers using upload API:
-
-  ```
-  curl -u "username:accesskey" -X POST "https://api.browserstack.com/app-automate/upload" -F "file=@/path/to/app/file/Application-debug.ipa"
-  ```
-
-- If you do not have an .ipa file and looking to simply try App Automate, [you can download our sample app and upload](https://www.browserstack.com/app-automate/sample-apps/ios/WordPressSample.ipa)
-to the BrowserStack servers using the above API.
-- Update the desired capability "app" with the App URL returned from the above API call
-
-For frameworks integration with BrowserStack, refer to their individual repositories -
-
-- [JUnit](https://github.com/browserstack/junit-appium-app-browserstack)
-- [TestNG](https://github.com/browserstack/testng-appium-app-browserstack)
\ No newline at end of file
diff --git a/java_7/README.md b/java_7/README.md
new file mode 100644
index 0000000..91d90d7
--- /dev/null
+++ b/java_7/README.md
@@ -0,0 +1,135 @@
+| Using Java 7 client with MJSONWP protocol | [Using Java 8 client with w3c protocol](../java_8) |
+|------------------------------------------ | -------------------------------------------------- |
+
+# java-appium-app-browserstack
+
+This repository demonstrates how to run Appium Java tests on BrowserStack App Automate.
+
+## Setup
+
+### Requirements
+
+1. Java 8+ (JDK)
+
+- If Java is not installed, follow these instructions:
+    - For Windows, download latest java version from [here](https://java.com/en/download/) and run the installer executable
+    - For Mac and Linux, run `java -version` to see what java version is pre-installed. If you want a different version download from [here](https://java.com/en/download/)
+
+2. Maven
+
+    - If Maven is not downloaded, download it from [here](https://maven.apache.org/download.cgi)
+    - For installation, follow the instructions [here](https://maven.apache.org/install.html)
+
+### Install the dependencies
+
+To install the dependencies, run the following command in the project's base folder
+
+```cmd
+mvn clean install
+```
+
+## Getting Started
+
+Getting Started with Appium tests in Java on BrowserStack couldn't be easier!
+
+### Run your first test :
+
+**1. Upload your Android or iOS App**
+
+Upload your Android app (.apk or .aab file) or iOS app (.ipa file) to BrowserStack servers using our REST API. Here is an example cURL request :
+
+```
+curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
+-X POST "https://api-cloud.browserstack.com/app-automate/upload" \
+-F "file=@/path/to/apk/file"
+```
+
+Ensure that @ symbol is prepended to the file path in the above request. Please note the `app_url` value returned in the API response. We will use this to set the application under test while configuring the test later on.
+
+**Note**: If you do not have an .apk or .ipa file and are looking to simply try App Automate, you can download and test using our [sample Android app](https://www.browserstack.com/app-automate/sample-apps/android/WikipediaSample.apk) or [sample iOS app](https://www.browserstack.com/app-automate/sample-apps/ios/BStackSampleApp.ipa).
+
+**2. Configure and run your first test**
+
+Open `BrowserStackSample.java` file in the `android` directory or `ios` directory :
+
+- Replace `YOUR_USERNAME` & `YOUR_ACCESS_KEY` with your BrowserStack access credentials. Get your BrowserStack access credentials from [here](https://www.browserstack.com/accounts/settings)
+
+- Replace `bs://<app-id>` with the URL obtained from app upload step
+
+- Set the device and OS version
+
+- If you have uploaded your own app update the test case
+
+- To run the test, use the following command in the base directory :
+
+    - For Android test, run
+
+    ```cmd
+    mvn test -P android-first-test
+    ```
+
+    - For iOS test, run
+
+    ```cmd
+    mvn test -P ios-first-test
+    ```
+
+- You can access the test execution results, and debugging information such as video recording, network logs on [App Automate dashboard](https://app-automate.browserstack.com/dashboard)
+
+---
+
+### Use Local testing for apps that access resources hosted in development or testing environments :
+
+**1. Upoad your Android or iOS App**
+
+Upload your Android app (.apk or .aab file) or iOS app (.ipa file) that access resources hosted on your internal or test environments to BrowserStack servers using our REST API. Here is an example cURL request :
+
+```
+curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
+-X POST "https://api-cloud.browserstack.com/app-automate/upload" \
+-F "file=@/path/to/apk/file"
+```
+
+Ensure that @ symbol is prepended to the file path in the above request. Please note the `app_url` value returned in the API response. We will use this to set the application under test while configuring the test later on.
+
+**Note**: If you do not have an .apk or .ipa file and are looking to simply try App Automate, you can download and test using our [sample Android Local app](https://www.browserstack.com/app-automate/sample-apps/android/LocalSample.apk) or [sample iOS Local app](https://www.browserstack.com/app-automate/sample-apps/ios/LocalSample.ipa).
+
+**2. Configure and run your local test**
+
+Open `BrowserStackSampleLocal.java` file in the `android` or `ios` directory :
+
+- Replace `YOUR_USERNAME` & `YOUR_ACCESS_KEY` with your BrowserStack access credentials. Get your BrowserStack access credentials from [here](https://www.browserstack.com/accounts/settings)
+
+- Replace `bs://<app-id>` with the URL obtained from app upload step
+
+- Set the device and OS version
+
+- Ensure that `browserstack.local` capability is set to `true`. Within the test script, there is code snippet that automatically establishes Local Testing connection to BrowserStack servers using Java binding for BrowserStack Local.
+
+- If you have uploaded your own app update the test case
+
+- To run the test, use the following command in the base directory :
+
+    - For Android test, run
+
+    ```cmd
+    mvn test -P android-local-test
+    ```
+
+    - For iOS test, run
+
+    ```cmd
+    mvn test -P ios-local-test
+    ```
+
+- You can access the test execution results, and debugging information such as video recording, network logs on [App Automate dashboard](https://app-automate.browserstack.com/dashboard)
+
+
+## Integration with other Java frameworks
+
+- [JUnit](https://github.com/browserstack/junit-appium-app-browserstack)
+- [TestNg](https://github.com/browserstack/testng-appium-app-browserstack)
+
+## Getting Help
+
+If you are running into any issues or have any queries, please check [Browserstack Support page](https://www.browserstack.com/support/app-automate) or [get in touch with us](https://www.browserstack.com/contact?ref=help).
diff --git a/java_7/pom.xml b/java_7/pom.xml
new file mode 100644
index 0000000..74fc8bd
--- /dev/null
+++ b/java_7/pom.xml
@@ -0,0 +1,160 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>com.browserstack</groupId>
+	<artifactId>java-browserstack</artifactId>
+	<version>0.0.1-SNAPSHOT</version>
+	<name>java-browserstack</name>
+	<description>Java appium app browserstack</description>
+
+	<properties>
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+		<surefire.version>2.19.1</surefire.version>
+		<test.file></test.file>
+		<config.file>default</config.file>
+	</properties>
+
+
+	<dependencies>
+		<dependency>
+			<groupId>commons-io</groupId>
+			<artifactId>commons-io</artifactId>
+			<version>1.3.2</version>
+		</dependency>
+		<dependency>
+			<groupId>io.appium</groupId>
+			<artifactId>java-client</artifactId>
+			<version>7.0.0</version>
+		</dependency>
+		<dependency>
+			<groupId>com.browserstack</groupId>
+			<artifactId>browserstack-local-java</artifactId>
+			<version>1.0.3</version>
+		</dependency>
+		<dependency>
+			<groupId>com.googlecode.json-simple</groupId>
+			<artifactId>json-simple</artifactId>
+			<version>1.1.1</version>
+		</dependency>
+	</dependencies>
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-surefire-plugin</artifactId>
+				<version>2.22.2</version>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<version>3.8.1</version>
+				<configuration>
+					<source>1.8</source>
+					<target>1.8</target>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
+
+	<profiles>
+		<profile>
+			<id>android-first-test</id>
+			<build>
+				<plugins>
+					<plugin>
+						<groupId>org.codehaus.mojo</groupId>
+						<artifactId>exec-maven-plugin</artifactId>
+						<version>1.1.1</version>
+						<executions>
+							<execution>
+								<phase>test</phase>
+								<goals>
+									<goal>java</goal>
+								</goals>
+								<configuration>
+									<mainClass>android.BrowserStackSample</mainClass>
+									<classpathScope>test</classpathScope>
+								</configuration>
+							</execution>
+						</executions>
+					</plugin>
+				</plugins>
+			</build>
+		</profile>
+		<profile>
+			<id>android-local-test</id>
+			<build>
+				<plugins>
+					<plugin>
+						<groupId>org.codehaus.mojo</groupId>
+						<artifactId>exec-maven-plugin</artifactId>
+						<version>1.1.1</version>
+						<executions>
+							<execution>
+								<phase>test</phase>
+								<goals>
+									<goal>java</goal>
+								</goals>
+								<configuration>
+									<mainClass>android.BrowserStackSampleLocal</mainClass>
+									<classpathScope>test</classpathScope>
+								</configuration>
+							</execution>
+						</executions>
+					</plugin>
+				</plugins>
+			</build>
+		</profile>
+		<profile>
+			<id>ios-first-test</id>
+			<build>
+				<plugins>
+					<plugin>
+						<groupId>org.codehaus.mojo</groupId>
+						<artifactId>exec-maven-plugin</artifactId>
+						<version>1.1.1</version>
+						<executions>
+							<execution>
+								<phase>test</phase>
+								<goals>
+									<goal>java</goal>
+								</goals>
+								<configuration>
+									<mainClass>ios.BrowserStackSample</mainClass>
+									<classpathScope>test</classpathScope>
+								</configuration>
+							</execution>
+						</executions>
+					</plugin>
+				</plugins>
+			</build>
+		</profile>
+		<profile>
+			<id>ios-local-test</id>
+			<build>
+				<plugins>
+					<plugin>
+						<groupId>org.codehaus.mojo</groupId>
+						<artifactId>exec-maven-plugin</artifactId>
+						<version>1.1.1</version>
+						<executions>
+							<execution>
+								<phase>test</phase>
+								<goals>
+									<goal>java</goal>
+								</goals>
+								<configuration>
+									<mainClass>ios.BrowserStackSampleLocal</mainClass>
+									<classpathScope>test</classpathScope>
+								</configuration>
+							</execution>
+						</executions>
+					</plugin>
+				</plugins>
+			</build>
+		</profile>
+	</profiles>
+
+</project>
\ No newline at end of file
diff --git a/java_7/src/test/java/android/BrowserStackSample.java b/java_7/src/test/java/android/BrowserStackSample.java
new file mode 100644
index 0000000..136ee81
--- /dev/null
+++ b/java_7/src/test/java/android/BrowserStackSample.java
@@ -0,0 +1,68 @@
+package android;
+
+import java.net.URL;
+import java.util.List;
+import java.util.function.Function;
+import java.net.MalformedURLException;
+
+import io.appium.java_client.MobileBy;
+import io.appium.java_client.android.AndroidDriver;
+import io.appium.java_client.android.AndroidElement;
+
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.remote.DesiredCapabilities;
+
+
+public class BrowserStackSample {
+
+	public static void main(String[] args) throws MalformedURLException, InterruptedException {
+		
+    	DesiredCapabilities caps = new DesiredCapabilities();
+    	
+    	// Set your access credentials
+    	caps.setCapability("browserstack.user", "YOUR_USERNAME");
+    	caps.setCapability("browserstack.key", "YOUR_ACCESS_KEY");
+    	
+    	// Set URL of the application under test
+    	caps.setCapability("app", "bs://<app-id>");
+    	
+    	// Specify device and os_version for testing
+    	caps.setCapability("device", "Google Pixel 3");
+    	caps.setCapability("os_version", "9.0");
+        
+    	// Set other BrowserStack capabilities
+    	caps.setCapability("project", "First Java Project");
+    	caps.setCapability("build", "browserstack-build-1");
+    	caps.setCapability("name", "first_test");
+       
+    	
+    	// Initialise the remote Webdriver using BrowserStack remote URL
+    	// and desired capabilities defined above
+        AndroidDriver<AndroidElement> driver = new AndroidDriver<AndroidElement>(
+        		new URL("http://hub.browserstack.com/wd/hub"), caps);
+        
+
+        // Test case for the BrowserStack sample Android app. 
+        // If you have uploaded your app, update the test case here. 
+        AndroidElement searchElement = (AndroidElement) new WebDriverWait(driver, 30).until(
+            ExpectedConditions.elementToBeClickable(
+            		MobileBy.AccessibilityId("Search Wikipedia")));
+        searchElement.click();
+		AndroidElement insertTextElement = (AndroidElement) new WebDriverWait(driver, 30).until(
+             ExpectedConditions.elementToBeClickable(
+            		 MobileBy.id("org.wikipedia.alpha:id/search_src_text")));
+        insertTextElement.sendKeys("BrowserStack");
+        Thread.sleep(5000);
+        List<AndroidElement> allProductsName = driver.findElementsByClassName(
+        		"android.widget.TextView");
+        assert(allProductsName.size() > 0);
+        
+        
+        // Invoke driver.quit() after the test is done to indicate that the test is completed.
+        driver.quit();
+		
+	}
+
+}
diff --git a/java_7/src/test/java/android/BrowserStackSampleLocal.java b/java_7/src/test/java/android/BrowserStackSampleLocal.java
new file mode 100644
index 0000000..0854db1
--- /dev/null
+++ b/java_7/src/test/java/android/BrowserStackSampleLocal.java
@@ -0,0 +1,90 @@
+package android;
+
+import com.browserstack.local.Local;
+import java.net.URL; import java.util.*;
+import io.appium.java_client.MobileBy; import io.appium.java_client.android.*;
+import org.openqa.selenium.support.ui.*;import org.openqa.selenium.remote.*;
+
+public class BrowserStackSampleLocal {
+	
+  private static Local localInstance;
+  public static String userName = "YOUR_USERNAME";
+  public static String accessKey = "YOUR_ACCESS_KEY";
+
+
+  public static void setupLocal() throws Exception {
+    localInstance = new Local();
+    Map<String, String> options = new HashMap<String, String>();
+    options.put("key", accessKey);
+    localInstance.start(options);
+  }
+
+  public static void tearDownLocal() throws Exception {
+    localInstance.stop();
+  }
+
+	public static void main(String[] args) throws Exception {
+      // Start the BrowserStack Local binary
+      setupLocal();
+
+      DesiredCapabilities capabilities = new DesiredCapabilities();
+
+    	// Set your access credentials
+    	capabilities.setCapability("browserstack.user", userName);
+    	capabilities.setCapability("browserstack.key", accessKey);
+
+    	// Set URL of the application under test
+    	capabilities.setCapability("app", "bs://<app-id>");
+
+    	// Specify device and os_version for testing
+    	capabilities.setCapability("device", "Google Pixel 3");
+    	capabilities.setCapability("os_version", "9.0");
+
+      // Set the browserstack.local capability to true
+      capabilities.setCapability("browserstack.local", true);
+
+      // Set other BrowserStack capabilities
+    	capabilities.setCapability("project", "First Java Project");
+    	capabilities.setCapability("build", "browserstack-build-1");
+    	capabilities.setCapability("name", "local_test");
+       
+
+   	  // Initialise the remote Webdriver using BrowserStack remote URL
+    	// and desired capabilities defined above
+      AndroidDriver<AndroidElement> driver = new AndroidDriver<AndroidElement>(
+        new URL("http://hub.browserstack.com/wd/hub"), capabilities);
+
+        // Test case for the BrowserStack sample Android Local app. 
+        // If you have uploaded your app, update the test case here.   
+        AndroidElement searchElement = (AndroidElement) new WebDriverWait(driver, 30).until(
+            ExpectedConditions.elementToBeClickable(MobileBy.id("com.example.android.basicnetworking:id/test_action")));
+        searchElement.click();
+        AndroidElement insertTextElement = (AndroidElement) new WebDriverWait(driver, 30).until(
+            ExpectedConditions.elementToBeClickable(MobileBy.className("android.widget.TextView")));
+
+        AndroidElement testElement = null;
+        List<AndroidElement> allTextViewElements = driver.findElementsByClassName("android.widget.TextView");
+        Thread.sleep(10);
+        for(AndroidElement textElement : allTextViewElements) {
+          if(textElement.getText().contains("The active connection is")) {
+            testElement = textElement;
+          }
+        }
+
+        if(testElement == null) {
+          throw new Error("Cannot find the needed TextView element from app");
+        }
+        String matchedString = testElement.getText();
+        System.out.println(matchedString);
+        assert(matchedString.contains("The active connection is wifi"));
+        assert(matchedString.contains("Up and running"));
+
+        // Invoke driver.quit() after the test is done to indicate that the test is completed.
+        driver.quit();
+
+        // Stop the BrowserStack Local binary
+        tearDownLocal();
+
+	}
+
+}
diff --git a/java_7/src/test/java/ios/BrowserStackSample.java b/java_7/src/test/java/ios/BrowserStackSample.java
new file mode 100644
index 0000000..1497bc3
--- /dev/null
+++ b/java_7/src/test/java/ios/BrowserStackSample.java
@@ -0,0 +1,42 @@
+package ios;
+import java.net.URL;
+import java.util.List;
+import java.net.MalformedURLException;
+import org.openqa.selenium.support.ui.WebDriverWait;
+import org.openqa.selenium.remote.DesiredCapabilities;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import io.appium.java_client.MobileBy;
+import io.appium.java_client.ios.IOSDriver;
+import io.appium.java_client.ios.IOSElement;
+public class BrowserStackSample {
+	public static void main(String[] args) throws MalformedURLException, InterruptedException {
+   	DesiredCapabilities caps = new DesiredCapabilities();
+    	
+    	// Set your access credentials
+    	caps.setCapability("browserstack.user", "abdullazizxs_M0W5GX");
+    	caps.setCapability("browserstack.key", "zS2Tit6YTbuhoCGgbB21");
+    	
+    	// Set URL of the application under test
+    	caps.setCapability("app", "bs://ff266c82636fc47ee3a615747bc9a7b63857a03d");
+    	
+    	// Specify device and os_version for testing
+        caps.setCapability("device", "iPhone XS");
+        caps.setCapability("os_version", "12");
+        
+    	// Set other BrowserStack capabilities
+    	caps.setCapability("project", "First Java Project");
+    	caps.setCapability("build", "browserstack-build-1");
+    	caps.setCapability("name", "first_test");
+    	
+    	
+    	// Initialise the remote Webdriver using BrowserStack remote URL
+    	// and desired capabilities defined above
+        IOSDriver<IOSElement> driver = new IOSDriver<IOSElement>(
+        		new URL("http://hub-cloud.browserstack.com/wd/hub"), caps);
+         
+        // Write your test case statements here
+        
+        // Invoke driver.quit() after the test is done to indicate that the test is completed.
+        driver.quit();
+	}
+}
diff --git a/ios/LocalSampleIOS.java b/java_7/src/test/java/ios/BrowserStackSampleLocal.java
similarity index 51%
rename from ios/LocalSampleIOS.java
rename to java_7/src/test/java/ios/BrowserStackSampleLocal.java
index 75ff044..a4af409 100644
--- a/ios/LocalSampleIOS.java
+++ b/java_7/src/test/java/ios/BrowserStackSampleLocal.java
@@ -1,28 +1,17 @@
-import com.browserstack.local.Local;
+package ios;
 
-import java.net.URL;
-import java.io.File;
-import java.util.Map;
-import java.util.HashMap;
+import com.browserstack.local.Local;
+import java.net.URL; import java.io.File; import java.util.*;
 import org.apache.commons.io.FileUtils;
+import io.appium.java_client.MobileBy; import io.appium.java_client.ios.*;
+import org.openqa.selenium.*;
+import org.openqa.selenium.support.ui.*;import org.openqa.selenium.remote.*;
 
-import io.appium.java_client.MobileBy;
-import io.appium.java_client.ios.IOSDriver;
-import io.appium.java_client.ios.IOSElement;
-
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.OutputType;
-import org.openqa.selenium.TakesScreenshot;
-import org.openqa.selenium.support.ui.WebDriverWait;
-import org.openqa.selenium.remote.DesiredCapabilities;
-import org.openqa.selenium.support.ui.ExpectedCondition;
-import org.openqa.selenium.support.ui.ExpectedConditions;
-
-
-public class LocalSampleIOS {
+public class BrowserStackSampleLocal {
+	
     private static Local localInstance;
-    public static String accessKey = "BROWSERSTACK_USERNAME";
-    public static String userName = "BROWSERSTACK_ACCESS_KEY";
+    public static String userName = "YOUR_USERNAME";
+    public static String accessKey = "YOUR_ACCESS_KEY";
   
 
     public static void setupLocal() throws Exception {
@@ -36,19 +25,39 @@ public static void tearDownLocal() throws Exception {
       localInstance.stop();
     }
 
-    public static void main(String[] args) throws Exception {
+
+	public static void main(String[] args) throws Exception {
+        // Start the BrowserStack Local binary
         setupLocal();
 
         DesiredCapabilities capabilities = new DesiredCapabilities();
 
-        capabilities.setCapability("browserstack.local", true);
-        capabilities.setCapability("realMobile", true);
-        capabilities.setCapability("device", "iPhone 7");
-        capabilities.setCapability("app", "bs://<hashed app-id>");
-        capabilities.setCapability("automationName", "XCUITest");
-
-        IOSDriver<IOSElement> driver = new IOSDriver<IOSElement>(new URL("http://"+userName+":"+accessKey+"@hub.browserstack.com/wd/hub"), capabilities);
-
+        // Set your access credentials
+    	  capabilities.setCapability("browserstack.user", userName);
+        capabilities.setCapability("browserstack.key", accessKey);
+        
+        // Set URL of the application under test
+       capabilities.setCapability("app", "bs://<app-id>");
+       
+       // Specify device and os_version for testing
+       capabilities.setCapability("device", "iPhone 12");
+       capabilities.setCapability("os_version", "13");
+
+      // Set the browserstack.local capability to true
+      capabilities.setCapability("browserstack.local", true);
+
+      // Set other BrowserStack capabilities
+    	capabilities.setCapability("project", "First Java Project");
+    	capabilities.setCapability("build", "browserstack-build-1");
+    	capabilities.setCapability("name", "local_test");
+        
+   	  // Initialise the remote Webdriver using BrowserStack remote URL
+      // and desired capabilities defined above
+      IOSDriver<IOSElement> driver = new IOSDriver<IOSElement>(
+        new URL("http://hub.browserstack.com/wd/hub"), capabilities);
+
+        // Test case for the BrowserStack sample iOS Local app. 
+        // If you have uploaded your app, update the test case here.   
         IOSElement testButton = (IOSElement) new WebDriverWait(driver, 30).until(
           ExpectedConditions.elementToBeClickable(MobileBy.AccessibilityId("TestBrowserStackLocal")));
         testButton.click();
@@ -75,8 +84,12 @@ public Boolean apply(WebDriver d) {
         String expectedString = "Up and running";
         assert(resultString.contains(expectedString.toLowerCase()));
 
+        // Invoke driver.quit() after the test is done to indicate that the test is completed.
         driver.quit();
-
+        
+        // Stop the BrowserStack Local binary
         tearDownLocal();
-    }
+		
+	}
+
 }
diff --git a/java_8/README.md b/java_8/README.md
new file mode 100644
index 0000000..4afdc79
--- /dev/null
+++ b/java_8/README.md
@@ -0,0 +1,175 @@
+| [Using Java 7 client with MJSONWP protocol](../java_7) | Using Java 8 client with w3c protocol |
+|------------------------------------------------------- | ------------------------------------- |
+
+# java-appium-app-browserstack
+
+This repository demonstrates how to run Appium Java tests on BrowserStack App Automate.
+
+## Setup
+
+### Requirements
+
+1. Java 8+ (JDK)
+
+- If Java is not installed, follow these instructions:
+    - For Windows, download latest java version from [here](https://java.com/en/download/) and run the installer executable
+    - For Mac and Linux, run `java -version` to see what java version is pre-installed. If you want a different version download from [here](https://java.com/en/download/)
+
+2. Maven
+
+    - If Maven is not downloaded, download it from [here](https://maven.apache.org/download.cgi)
+    - For installation, follow the instructions [here](https://maven.apache.org/install.html)
+
+### Install the dependencies
+
+To install the dependencies, run the following command in the project's base folder
+
+```cmd
+mvn clean install
+```
+
+## Getting Started
+
+Getting Started with Appium tests in Java on BrowserStack couldn't be easier!
+
+### For java-client 8.0.0 and above
+
+- Any BrowserStack capability passed outside bstack:options will not be honoured \
+[Browserstack Capability Builder](https://www.browserstack.com/app-automate/capabilities?tag=w3c)
+
+- AppiumBy is available with java-client 8.0.0 as MobileBy is depreceated . For java-client < 8.0.0, MobileBy can be used.
+
+- DefaultGenericMobileElement class has been removed completely together with its descendants (MobileElement, IOSElement, AndroidElement etc.). Use WebElement instead.
+
+- WebDriverWait constructor requires time to be passed as a type Duration. So with java-client 8.0.0, pass wait time as a new Duration
+    **java-client v-7.0.0**
+    ```
+     WebElement searchElement = (WebElement) new WebDriverWait(driver, 30)
+    ```
+    
+    **java-client v-8.0.0**
+    ```
+     import java.time.Duration;
+     WebElement searchElement = (WebElement) new WebDriverWait(driver, Duration.ofSeconds(30))
+    ```
+    
+  Refer this for tracking changes in java-client 8.0.0 documentation - [v7-to-v8-migration-guide](https://github.com/appium/java-client/blob/master/docs/v7-to-v8-migration-guide.md#mobileelement)
+
+### Run your first test :
+
+**1. Upload your Android or iOS App**
+
+Upload your Android app (.apk or .aab file) or iOS app (.ipa file) to BrowserStack servers using our REST API. Here is an example cURL request :
+
+```
+curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
+-X POST "https://api-cloud.browserstack.com/app-automate/upload" \
+-F "file=@/path/to/apk/file"
+```
+
+Ensure that @ symbol is prepended to the file path in the above request. Please note the `app_url` value returned in the API response. We will use this to set the application under test while configuring the test later on.
+
+**Note**: If you do not have an .apk or .ipa file and are looking to simply try App Automate, you can download and test using our [sample Android app](https://www.browserstack.com/app-automate/sample-apps/android/WikipediaSample.apk) or [sample iOS app](https://www.browserstack.com/app-automate/sample-apps/ios/BStackSampleApp.ipa).
+
+**2. Configure and run your first test**
+
+Open `BrowserStackSample.java` file in the `android` directory or `ios` directory :
+
+- Replace `YOUR_USERNAME` & `YOUR_ACCESS_KEY` with your BrowserStack access credentials. Get your BrowserStack access credentials from [here](https://www.browserstack.com/accounts/settings)
+
+- Replace `bs://<app-id>` with the URL obtained from app upload step
+
+- Set the device and OS version
+
+- If you have uploaded your own app update the test case
+
+- To run the test, use the following command in the base directory :
+
+    - For Android test, run
+
+    ```cmd
+    mvn test -P android-first-test
+    ```
+
+    - For iOS test, run
+
+    ```cmd
+    mvn test -P ios-first-test
+    ```
+
+- You can access the test execution results, and debugging information such as video recording, network logs on [App Automate dashboard](https://app-automate.browserstack.com/dashboard)
+
+---
+
+### Use Local testing for apps that access resources hosted in development or testing environments :
+
+**1. Upoad your Android or iOS App**
+
+Upload your Android app (.apk or .aab file) or iOS app (.ipa file) that access resources hosted on your internal or test environments to BrowserStack servers using our REST API. Here is an example cURL request :
+
+```
+curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
+-X POST "https://api-cloud.browserstack.com/app-automate/upload" \
+-F "file=@/path/to/apk/file"
+```
+
+Ensure that @ symbol is prepended to the file path in the above request. Please note the `app_url` value returned in the API response. We will use this to set the application under test while configuring the test later on.
+
+**Note**: If you do not have an .apk or .ipa file and are looking to simply try App Automate, you can download and test using our [sample Android Local app](https://www.browserstack.com/app-automate/sample-apps/android/LocalSample.apk) or [sample iOS Local app](https://www.browserstack.com/app-automate/sample-apps/ios/LocalSample.ipa).
+
+**2. Configure and run your local test**
+
+Local Testing is a BrowserStack feature that helps you test mobile apps that access resources hosted in development or testing environments during automated test execution
+
+**i. Setup Browserstack Local Testing connection :**
+
+Check the releases page to download the binary / native application [Browserstack Local Releases](https://www.browserstack.com/docs/local-testing/releases-and-downloads)
+
+- Option 1
+    - Use Browserstack Local Binary - [Local Binary](https://www.browserstack.com/docs/app-automate/appium/getting-started/java/local-testing)
+- Option 2
+    - Use Browserstack native application - [Local Native App](https://www.browserstack.com/docs/local-testing/local-app-upgrade-guide)
+
+
+NOTE : If you're unable to run the LocalTesting Binary / Native application due to Apple permission issues, go to \
+    ```
+        System preferences -> Security and privacy -> General -> Allow app
+    ```
+
+**ii. Open `BrowserStackSampleLocal.java` file in the `android` or `ios` directory :**
+
+- Replace `YOUR_USERNAME` & `YOUR_ACCESS_KEY` with your BrowserStack access credentials. Get your BrowserStack access credentials from [here](https://www.browserstack.com/accounts/settings)
+
+- Replace `bs://<app-id>` with the URL obtained from app upload step
+
+- Set the device and OS version
+
+- Ensure that `browserstack.local` capability is set to `true`. Within the test script, there is code snippet that automatically establishes Local Testing connection to BrowserStack servers using Java binding for BrowserStack Local.
+
+- If you have uploaded your own app update the test case
+
+- To run the test, use the following command in the base directory :
+
+    - For Android test, run
+
+    ```cmd
+    mvn test -P android-local-test
+    ```
+
+    - For iOS test, run
+
+    ```cmd
+    mvn test -P ios-local-test
+    ```
+
+- You can access the test execution results, and debugging information such as video recording, network logs on [App Automate dashboard](https://app-automate.browserstack.com/dashboard)
+
+
+## Integration with other Java frameworks
+
+- [JUnit](https://github.com/browserstack/junit-appium-app-browserstack)
+- [TestNg](https://github.com/browserstack/testng-appium-app-browserstack)
+
+## Getting Help
+
+If you are running into any issues or have any queries, please check [Browserstack Support page](https://www.browserstack.com/support/app-automate) or [get in touch with us](https://www.browserstack.com/contact?ref=help).
diff --git a/java_8/pom.xml b/java_8/pom.xml
new file mode 100644
index 0000000..300166e
--- /dev/null
+++ b/java_8/pom.xml
@@ -0,0 +1,160 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>com.browserstack</groupId>
+	<artifactId>java-browserstack</artifactId>
+	<version>0.0.1-SNAPSHOT</version>
+	<name>java-browserstack</name>
+	<description>Java appium app browserstack</description>
+
+	<properties>
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+		<surefire.version>2.19.1</surefire.version>
+		<test.file></test.file>
+		<config.file>default</config.file>
+	</properties>
+
+
+	<dependencies>
+		<dependency>
+			<groupId>commons-io</groupId>
+			<artifactId>commons-io</artifactId>
+			<version>1.3.2</version>
+		</dependency>
+		<dependency>
+			<groupId>io.appium</groupId>
+			<artifactId>java-client</artifactId>
+			<version>8.0.0</version>
+		</dependency>
+		<dependency>
+			<groupId>com.browserstack</groupId>
+			<artifactId>browserstack-local-java</artifactId>
+			<version>1.0.3</version>
+		</dependency>
+		<dependency>
+			<groupId>com.googlecode.json-simple</groupId>
+			<artifactId>json-simple</artifactId>
+			<version>1.1.1</version>
+		</dependency>
+	</dependencies>
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-surefire-plugin</artifactId>
+				<version>2.22.2</version>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<version>3.8.1</version>
+				<configuration>
+					<source>1.8</source>
+					<target>1.8</target>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
+
+	<profiles>
+		<profile>
+			<id>android-first-test</id>
+			<build>
+				<plugins>
+					<plugin>
+						<groupId>org.codehaus.mojo</groupId>
+						<artifactId>exec-maven-plugin</artifactId>
+						<version>1.1.1</version>
+						<executions>
+							<execution>
+								<phase>test</phase>
+								<goals>
+									<goal>java</goal>
+								</goals>
+								<configuration>
+									<mainClass>android.BrowserStackSample</mainClass>
+									<classpathScope>test</classpathScope>
+								</configuration>
+							</execution>
+						</executions>
+					</plugin>
+				</plugins>
+			</build>
+		</profile>
+		<profile>
+			<id>android-local-test</id>
+			<build>
+				<plugins>
+					<plugin>
+						<groupId>org.codehaus.mojo</groupId>
+						<artifactId>exec-maven-plugin</artifactId>
+						<version>1.1.1</version>
+						<executions>
+							<execution>
+								<phase>test</phase>
+								<goals>
+									<goal>java</goal>
+								</goals>
+								<configuration>
+									<mainClass>android.BrowserStackSampleLocal</mainClass>
+									<classpathScope>test</classpathScope>
+								</configuration>
+							</execution>
+						</executions>
+					</plugin>
+				</plugins>
+			</build>
+		</profile>
+		<profile>
+			<id>ios-first-test</id>
+			<build>
+				<plugins>
+					<plugin>
+						<groupId>org.codehaus.mojo</groupId>
+						<artifactId>exec-maven-plugin</artifactId>
+						<version>1.1.1</version>
+						<executions>
+							<execution>
+								<phase>test</phase>
+								<goals>
+									<goal>java</goal>
+								</goals>
+								<configuration>
+									<mainClass>ios.BrowserStackSample</mainClass>
+									<classpathScope>test</classpathScope>
+								</configuration>
+							</execution>
+						</executions>
+					</plugin>
+				</plugins>
+			</build>
+		</profile>
+		<profile>
+			<id>ios-local-test</id>
+			<build>
+				<plugins>
+					<plugin>
+						<groupId>org.codehaus.mojo</groupId>
+						<artifactId>exec-maven-plugin</artifactId>
+						<version>1.1.1</version>
+						<executions>
+							<execution>
+								<phase>test</phase>
+								<goals>
+									<goal>java</goal>
+								</goals>
+								<configuration>
+									<mainClass>ios.BrowserStackSampleLocal</mainClass>
+									<classpathScope>test</classpathScope>
+								</configuration>
+							</execution>
+						</executions>
+					</plugin>
+				</plugins>
+			</build>
+		</profile>
+	</profiles>
+
+</project>
\ No newline at end of file
diff --git a/java_8/src/test/java/android/BrowserStackSample.java b/java_8/src/test/java/android/BrowserStackSample.java
new file mode 100644
index 0000000..c923568
--- /dev/null
+++ b/java_8/src/test/java/android/BrowserStackSample.java
@@ -0,0 +1,83 @@
+package android;
+
+import io.appium.java_client.AppiumBy;
+import io.appium.java_client.android.AndroidDriver;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.time.Duration;
+import java.util.HashMap;
+import java.util.List;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.remote.DesiredCapabilities;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
+
+public class BrowserStackSample {
+
+  public static void main(String[] args)
+    throws MalformedURLException, InterruptedException {
+    DesiredCapabilities caps = new DesiredCapabilities();
+    HashMap<String, Object> browserstackOptions = new HashMap<String, Object>();
+
+    // Set your access credentials
+    browserstackOptions.put("userName", "YOUR_USERNAME");
+    browserstackOptions.put("accessKey", "YOUR_ACCESS_KEY");
+
+    // Set other BrowserStack capabilities
+    browserstackOptions.put("appiumVersion", "1.22.0");
+    browserstackOptions.put("projectName", "First Java Project");
+    browserstackOptions.put("buildName", "browserstack-build-1");
+    browserstackOptions.put("sessionName", "first_test");
+
+    // Passing browserstack capabilities inside bstack:options
+    caps.setCapability("bstack:options", browserstackOptions);
+
+    // Set URL of the application under test
+    caps.setCapability("app", "bs://<app-id>");
+
+    // Specify deviceName and platformName for testing
+    caps.setCapability("deviceName", "Google Pixel 3");
+    caps.setCapability("platformName", "android");
+    caps.setCapability("platformVersion", "9.0");
+
+    // Initialise the remote Webdriver using BrowserStack remote URL
+    // and desired capabilities defined above
+    AndroidDriver driver = new AndroidDriver(
+      new URL("http://hub.browserstack.com/wd/hub"),
+      caps
+    );
+
+    // Test case for the BrowserStack sample Android app.
+    // If you have uploaded your app, update the test case here.
+    WebElement searchElement = (WebElement) new WebDriverWait(
+      driver,
+      Duration.ofSeconds(30)
+    )
+    .until(
+        ExpectedConditions.elementToBeClickable(
+          AppiumBy.accessibilityId("Search Wikipedia")
+        )
+      );
+    searchElement.click();
+
+    WebElement insertTextElement = (WebElement) new WebDriverWait(
+      driver,
+      Duration.ofSeconds(30)
+    )
+    .until(
+        ExpectedConditions.elementToBeClickable(
+          AppiumBy.id("org.wikipedia.alpha:id/search_src_text")
+        )
+      );
+    insertTextElement.sendKeys("BrowserStack");
+    Thread.sleep(5000);
+
+    List<WebElement> allProductsName = driver.findElements(
+      AppiumBy.className("android.widget.TextView")
+    );
+    assert (allProductsName.size() > 0);
+
+    // Invoke driver.quit() after the test is done to indicate that the test is completed.
+    driver.quit();
+  }
+}
diff --git a/java_8/src/test/java/android/BrowserStackSampleLocal.java b/java_8/src/test/java/android/BrowserStackSampleLocal.java
new file mode 100644
index 0000000..e765543
--- /dev/null
+++ b/java_8/src/test/java/android/BrowserStackSampleLocal.java
@@ -0,0 +1,114 @@
+package android;
+
+import com.browserstack.local.Local;
+import io.appium.java_client.AppiumBy;
+import io.appium.java_client.android.AndroidDriver;
+import java.net.URL;
+import java.time.Duration;
+import java.util.*;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.remote.*;
+import org.openqa.selenium.support.ui.*;
+
+public class BrowserStackSampleLocal {
+
+  private static Local localInstance;
+  public static String userName = "YOUR_USERNAME";
+  public static String accessKey = "YOUR_ACCESS_KEY";
+
+  public static void setupLocal() throws Exception {
+    localInstance = new Local();
+    Map<String, String> options = new HashMap<String, String>();
+    options.put("key", accessKey);
+    options.put("local", "true");
+    localInstance.start(options);
+  }
+
+  public static void tearDownLocal() throws Exception {
+    localInstance.stop();
+  }
+
+  public static void main(String[] args) throws Exception {
+    // Start the BrowserStack Local binary
+    setupLocal();
+
+    DesiredCapabilities capabilities = new DesiredCapabilities();
+    HashMap<String, Object> browserstackOptions = new HashMap<String, Object>();
+
+    // Set your access credentials
+    browserstackOptions.put("userName", userName);
+    browserstackOptions.put("accessKey", accessKey);
+
+    // Set other BrowserStack capabilities
+    browserstackOptions.put("appiumVersion", "1.22.0");
+    browserstackOptions.put("projectName", "First Java Project");
+    browserstackOptions.put("buildName", "browserstack-build-1");
+    browserstackOptions.put("sessionName", "local_test");
+
+    // Set the browserstack.local capability to true
+    browserstackOptions.put("local", "true");
+
+    // Passing browserstack capabilities inside bstack:options
+    capabilities.setCapability("bstack:options", browserstackOptions);
+
+    // Set URL of the application under test
+    capabilities.setCapability("app", "bs://<app-id>");
+
+    // Specify device and os_version for testing
+    capabilities.setCapability("deviceName", "Google Pixel 3");
+    capabilities.setCapability("platformName", "android");
+    capabilities.setCapability("platformVersion", "9.0");
+
+    // Initialise the remote Webdriver using BrowserStack remote URL
+    // and desired capabilities defined above
+    AndroidDriver driver = new AndroidDriver(
+      new URL("http://hub.browserstack.com/wd/hub"),
+      capabilities
+    );
+
+    // Test case for the BrowserStack sample Android Local app.
+    // If you have uploaded your app, update the test case here.
+    WebElement searchElement = new WebDriverWait(driver, Duration.ofSeconds(30))
+    .until(
+        ExpectedConditions.elementToBeClickable(
+          AppiumBy.id("com.example.android.basicnetworking:id/test_action")
+        )
+      );
+    searchElement.click();
+
+    WebElement insertTextElement = (WebElement) new WebDriverWait(
+      driver,
+      Duration.ofSeconds(30)
+    )
+    .until(
+        ExpectedConditions.elementToBeClickable(
+          AppiumBy.className("android.widget.TextView")
+        )
+      );
+
+    WebElement testElement = null;
+    List<WebElement> allTextViewElements = driver.findElements(
+      AppiumBy.className("android.widget.TextView")
+    );
+    Thread.sleep(10);
+    for (WebElement textElement : allTextViewElements) {
+      if (textElement.getText().contains("The active connection is")) {
+        testElement = textElement;
+      }
+    }
+
+    if (testElement == null) {
+      throw new Error("Cannot find the needed TextView element from app");
+    }
+    String matchedString = testElement.getText();
+    System.out.println(matchedString);
+    assert (matchedString.contains("The active connection is wifi"));
+    assert (matchedString.contains("Up and running"));
+
+    // Invoke driver.quit() after the test is done to indicate that the test is completed.
+    driver.quit();
+
+    // Stop the BrowserStack Local binary
+    tearDownLocal();
+  }
+}
diff --git a/java_8/src/test/java/ios/BrowserStackSample.java b/java_8/src/test/java/ios/BrowserStackSample.java
new file mode 100644
index 0000000..09d2013
--- /dev/null
+++ b/java_8/src/test/java/ios/BrowserStackSample.java
@@ -0,0 +1,91 @@
+package ios;
+
+import io.appium.java_client.AppiumBy;
+import io.appium.java_client.ios.IOSDriver;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.time.Duration;
+import java.util.HashMap;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.remote.DesiredCapabilities;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
+
+public class BrowserStackSample {
+
+  public static void main(String[] args)
+    throws MalformedURLException, InterruptedException {
+    DesiredCapabilities caps = new DesiredCapabilities();
+    HashMap<String, Object> browserstackOptions = new HashMap<String, Object>();
+
+    // Set your access credentials
+    browserstackOptions.put("userName", "YOUR_USERNAME");
+    browserstackOptions.put("accessKey", "YOUR_ACCESS_KEY");
+
+    // Set other BrowserStack capabilities
+    browserstackOptions.put("appiumVersion", "1.22.0");
+    browserstackOptions.put("projectName", "First Java Project");
+    browserstackOptions.put("buildName", "browserstack-build-1");
+    browserstackOptions.put("sessionName", "first_test");
+
+    // Passing browserstack capabilities inside bstack:options
+    caps.setCapability("bstack:options", browserstackOptions);
+
+    // Set URL of the application under test
+    caps.setCapability("app", "bs://<app-id>");
+
+    // Specify device and os_version for testing
+    caps.setCapability("deviceName", "iPhone 12");
+    caps.setCapability("platformName", "ios");
+    caps.setCapability("platformVersion", "13");
+
+    // Initialise the remote Webdriver using BrowserStack remote URL
+    // and desired capabilities defined above
+    IOSDriver driver = new IOSDriver(
+      new URL("http://hub.browserstack.com/wd/hub"),
+      caps
+    );
+
+    // Test case for the BrowserStack sample iOS app.
+    // If you have uploaded your app, update the test case here.
+    WebElement textButton = (WebElement) new WebDriverWait(
+      driver,
+      Duration.ofSeconds(30)
+    )
+    .until(
+        ExpectedConditions.elementToBeClickable(
+          AppiumBy.accessibilityId("Text Button")
+        )
+      );
+    textButton.click();
+
+    WebElement textInput = (WebElement) new WebDriverWait(
+      driver,
+      Duration.ofSeconds(30)
+    )
+    .until(
+        ExpectedConditions.elementToBeClickable(
+          AppiumBy.accessibilityId("Text Input")
+        )
+      );
+    textInput.sendKeys("hello@browserstack.com");
+    Thread.sleep(5000);
+
+    WebElement textOutput = (WebElement) new WebDriverWait(
+      driver,
+      Duration.ofSeconds(30)
+    )
+    .until(
+        ExpectedConditions.elementToBeClickable(
+          AppiumBy.accessibilityId("Text Output")
+        )
+      );
+    if (
+      textOutput != null &&
+      textOutput.getText().equals("hello@browserstack.com")
+    ) assert (true); else assert (false);
+
+    // Invoke driver.quit() after the test is done to indicate that the test is completed.
+    driver.quit();
+  }
+}
diff --git a/java_8/src/test/java/ios/BrowserStackSampleLocal.java b/java_8/src/test/java/ios/BrowserStackSampleLocal.java
new file mode 100644
index 0000000..0493d13
--- /dev/null
+++ b/java_8/src/test/java/ios/BrowserStackSampleLocal.java
@@ -0,0 +1,129 @@
+package ios;
+
+import com.browserstack.local.Local;
+import io.appium.java_client.AppiumBy;
+import io.appium.java_client.ios.IOSDriver;
+import java.io.File;
+import java.net.URL;
+import java.time.Duration;
+import java.util.*;
+import org.apache.commons.io.FileUtils;
+import org.openqa.selenium.*;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.remote.*;
+import org.openqa.selenium.support.ui.*;
+
+public class BrowserStackSampleLocal {
+
+  private static Local localInstance;
+  public static String userName = "YOUR_USERNAME";
+  public static String accessKey = "YOUR_ACCESS_KEY";
+
+  public static void setupLocal() throws Exception {
+    localInstance = new Local();
+    Map<String, String> options = new HashMap<String, String>();
+    options.put("key", accessKey);
+    options.put("local", "true");
+    localInstance.start(options);
+  }
+
+  public static void tearDownLocal() throws Exception {
+    localInstance.stop();
+  }
+
+  public static void main(String[] args) throws Exception {
+    // Start the BrowserStack Local binary
+    setupLocal();
+
+    DesiredCapabilities capabilities = new DesiredCapabilities();
+    HashMap<String, Object> browserstackOptions = new HashMap<String, Object>();
+
+    // Set your access credentials
+    browserstackOptions.put("userName", userName);
+    browserstackOptions.put("accessKey", accessKey);
+
+    // Set other BrowserStack capabilities
+    browserstackOptions.put("appiumVersion", "1.22.0");
+    browserstackOptions.put("projectName", "First Java Project");
+    browserstackOptions.put("buildName", "browserstack-build-1");
+    browserstackOptions.put("sessionName", "local_test");
+
+    // Set the browserstack.local capability to true
+    browserstackOptions.put("local", "true");
+
+    // Passing browserstack capabilities inside bstack:options
+    capabilities.setCapability("bstack:options", browserstackOptions);
+
+    // Set URL of the application under test
+    capabilities.setCapability("app", "bs://<app-id>");
+
+    // Specify device and os_version for testing
+    capabilities.setCapability("deviceName", "iPhone 12");
+    capabilities.setCapability("platformName", "ios");
+    capabilities.setCapability("platformVersion", "13");
+
+    // Initialise the remote Webdriver using BrowserStack remote URL
+    // and desired capabilities defined above
+    IOSDriver driver = new IOSDriver(
+      new URL("http://hub.browserstack.com/wd/hub"),
+      capabilities
+    );
+
+    // Test case for the BrowserStack sample iOS Local app.
+    // If you have uploaded your app, update the test case here.
+    WebElement testButton = (WebElement) new WebDriverWait(
+      driver,
+      Duration.ofSeconds(30)
+    )
+    .until(
+        ExpectedConditions.elementToBeClickable(
+          AppiumBy.accessibilityId("TestBrowserStackLocal")
+        )
+      );
+    testButton.click();
+
+    WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(30));
+    wait.until(
+      new ExpectedCondition<Boolean>() {
+        @Override
+        public Boolean apply(WebDriver d) {
+          String result = d
+            .findElement(AppiumBy.accessibilityId("ResultBrowserStackLocal"))
+            .getAttribute("value");
+          return result != null && result.length() > 0;
+        }
+      }
+    );
+    WebElement resultElement = (WebElement) driver.findElement(
+      AppiumBy.accessibilityId("ResultBrowserStackLocal")
+    );
+
+    String resultString = resultElement.getText().toLowerCase();
+    System.out.println(resultString);
+    if (resultString.contains("not working")) {
+      File scrFile = (File) ((TakesScreenshot) driver).getScreenshotAs(
+          OutputType.FILE
+        );
+      FileUtils.copyFile(
+        scrFile,
+        new File(System.getProperty("user.dir") + "/screenshot.png")
+      );
+      System.out.println(
+        "Screenshot stored at " +
+        System.getProperty("user.dir") +
+        "/screenshot.png"
+      );
+      throw new Error("Unexpected BrowserStackLocal test result");
+    }
+
+    String expectedString = "Up and running";
+    assert (resultString.contains(expectedString.toLowerCase()));
+
+    // Invoke driver.quit() after the test is done to indicate that the test is completed.
+    driver.quit();
+
+    // Stop the BrowserStack Local binary
+    tearDownLocal();
+  }
+}